﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Production.DomainLib.AggregatesModel.StandardBomAggregate;

namespace Production.InfrastructureLib.EntityConfigurations
{
    public class StandardBomEntityTypeConfiguration : IEntityTypeConfiguration<StandardBom>
    {
        public void Configure(EntityTypeBuilder<StandardBom> builder)
        {
            builder.ToTable("MES_STANDARDBOM");

            var navigation = builder.Metadata.FindNavigation(nameof(StandardBom.Items));

            // DDD Patterns comment:
            //Set as field (New since EF 1.1) to access the OrderItem collection property through its field
            navigation?.SetPropertyAccessMode(PropertyAccessMode.Field);
        }
    }
}